import { StaffFees } from './staffFee';
let _StaffFees = StaffFees;
/**
 * 拷贝下面两行到 mock/index.js中,即可支持客户端虚拟数据、免服务端连接
 * import StaffFeeMock from './mk/mng/computed/staffFeeMock';
 * StaffFeeMock.bootstrap(mock);
 */
export default {
  /**
   * mock bootstrap
   */
  bootstrap(mock) {    
  
    //获取列表 模糊查询、根据关键字查询
    mock.onGet('/mk/mng/computed/staffFee/listKey').reply(config => {
      let params = config.params;
      let mockStaffFees = _StaffFees.filter(staffFee => {
      	if(params.mkStaff||params.mkStaff==''){ if( staffFee.mkStaff.indexOf(params.mkStaff)>=0) return true;}
      	if(params.orderId||params.orderId==''){ if( staffFee.orderId.indexOf(params.orderId)>=0) return true;}
      	if(params.orderTotalFee||params.orderTotalFee==''){ if( staffFee.orderTotalFee.indexOf(params.orderTotalFee)>=0) return true;}
      	if(params.orderTotalAmount||params.orderTotalAmount==''){ if( staffFee.orderTotalAmount.indexOf(params.orderTotalAmount)>=0) return true;}
      	if(params.orderActPayAmount||params.orderActPayAmount==''){ if( staffFee.orderActPayAmount.indexOf(params.orderActPayAmount)>=0) return true;}
      	if(params.orderReduceAmount||params.orderReduceAmount==''){ if( staffFee.orderReduceAmount.indexOf(params.orderReduceAmount)>=0) return true;}
      	if(params.custId||params.custId==''){ if( staffFee.custId.indexOf(params.custId)>=0) return true;}
      	if(params.flowId||params.flowId==''){ if( staffFee.flowId.indexOf(params.flowId)>=0) return true;}
      	if(params.status||params.status==''){ if( staffFee.status.indexOf(params.status)>=0) return true;}
      	if(params.flowStatus||params.flowStatus==''){ if( staffFee.flowStatus.indexOf(params.flowStatus)>=0) return true;}
      	if(params.acctDate||params.acctDate==''){ if( staffFee.acctDate.indexOf(params.acctDate)>=0) return true;}
      	if(params.accountDate||params.accountDate==''){ if( staffFee.accountDate.indexOf(params.accountDate)>=0) return true;}
      	if(params.staffFee||params.staffFee==''){ if( staffFee.staffFee.indexOf(params.staffFee)>=0) return true;}
      	if(params.startComputedDate||params.startComputedDate==''){ if( staffFee.startComputedDate.indexOf(params.startComputedDate)>=0) return true;}
      	if(params.id||params.id==''){ if( staffFee.id.indexOf(params.id)>=0) return true;}
      	if(params.feeDesc||params.feeDesc==''){ if( staffFee.feeDesc.indexOf(params.feeDesc)>=0) return true;}
      	if(params.orderPayDate||params.orderPayDate==''){ if( staffFee.orderPayDate.indexOf(params.orderPayDate)>=0) return true;}
      	if(params.feePct||params.feePct==''){ if( staffFee.feePct.indexOf(params.feePct)>=0) return true;}
      	if(params.staffCount||params.staffCount==''){ if( staffFee.staffCount.indexOf(params.staffCount)>=0) return true;}
      	if(params.districtId||params.districtId==''){ if( staffFee.districtId.indexOf(params.districtId)>=0) return true;}
      	if(params.mkStaffName||params.mkStaffName==''){ if( staffFee.mkStaffName.indexOf(params.mkStaffName)>=0) return true;}
      	if(params.custName||params.custName==''){ if( staffFee.custName.indexOf(params.custName)>=0) return true;}
        return false;
      });
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve([200, {
            data: mockStaffFees
          }]);
        }, 1000);
      });
    });
    
    

    //获取列表（分页/不分页）
    mock.onGet('/mk/mng/computed/staffFee/list').reply(config => {
      let params = config.params;
      let mockStaffFees = _StaffFees.filter(staffFee => {
      	var isTrue=false;
      	if(params.mkStaff||params.mkStaff==''){if(staffFee.mkStaff.indexOf(params.mkStaff)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.orderId||params.orderId==''){if(staffFee.orderId.indexOf(params.orderId)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.orderTotalFee||params.orderTotalFee==''){if(staffFee.orderTotalFee.indexOf(params.orderTotalFee)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.orderTotalAmount||params.orderTotalAmount==''){if(staffFee.orderTotalAmount.indexOf(params.orderTotalAmount)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.orderActPayAmount||params.orderActPayAmount==''){if(staffFee.orderActPayAmount.indexOf(params.orderActPayAmount)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.orderReduceAmount||params.orderReduceAmount==''){if(staffFee.orderReduceAmount.indexOf(params.orderReduceAmount)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.custId||params.custId==''){if(staffFee.custId.indexOf(params.custId)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.flowId||params.flowId==''){if(staffFee.flowId.indexOf(params.flowId)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.status||params.status==''){if(staffFee.status.indexOf(params.status)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.flowStatus||params.flowStatus==''){if(staffFee.flowStatus.indexOf(params.flowStatus)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.acctDate||params.acctDate==''){if(staffFee.acctDate.indexOf(params.acctDate)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.accountDate||params.accountDate==''){if(staffFee.accountDate.indexOf(params.accountDate)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.staffFee||params.staffFee==''){if(staffFee.staffFee.indexOf(params.staffFee)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.startComputedDate||params.startComputedDate==''){if(staffFee.startComputedDate.indexOf(params.startComputedDate)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.id||params.id==''){if(staffFee.id.indexOf(params.id)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.feeDesc||params.feeDesc==''){if(staffFee.feeDesc.indexOf(params.feeDesc)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.orderPayDate||params.orderPayDate==''){if(staffFee.orderPayDate.indexOf(params.orderPayDate)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.feePct||params.feePct==''){if(staffFee.feePct.indexOf(params.feePct)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.staffCount||params.staffCount==''){if(staffFee.staffCount.indexOf(params.staffCount)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.districtId||params.districtId==''){if(staffFee.districtId.indexOf(params.districtId)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.mkStaffName||params.mkStaffName==''){if(staffFee.mkStaffName.indexOf(params.mkStaffName)>=0){isTrue=true;}else{isTrue=false;}}
      	if(params.custName||params.custName==''){if(staffFee.custName.indexOf(params.custName)>=0){isTrue=true;}else{isTrue=false;}}
      	return isTrue;
	  });
      if(!config.params.currentPage){ 
	      return new Promise((resolve, reject) => {
	        setTimeout(() => {
	          resolve([200, {
	            data: mockStaffFees
	          }]);
	        }, 1000);
	      });
      }
    
      let {pageSize,currentPage, total} = config.params;
      total = mockStaffFees.length;
      mockStaffFees = mockStaffFees.filter((staffFee, index) => index < pageSize * currentPage && index >= pageSize * (currentPage - 1));
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve([200, {
            pageInfo: {
            	total:total
            },
            data: mockStaffFees,
            tips:{
            	isOk:true,
            	msg:'查询成功'
            }
          }]);
        }, 1000);
      });
    });

    //删除
    mock.onPost('/mk/mng/computed/staffFee/del').reply(config => {
      var params = JSON.parse( config.data );
      let {  id  } = params;
      _StaffFees = _StaffFees.filter(staffFee => staffFee.id !== id);
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve([200, {
            tips:{
            	isOk:true,
            	msg:'删除成功'
            }
          }]);
        }, 500);
      });
    });

    //批量删除
    mock.onPost('/mk/mng/computed/staffFee/batchDel').reply(config => {
      var params = JSON.parse( config.data );
      _StaffFees = _StaffFees.filter(staffFee => !params.includes(staffFee.id));
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve([200, {
           tips:{
            	isOk:true,
            	msg:'删除成功'
            }
          }]);
        }, 500);
      });
    });

    //编辑
    mock.onPost('/mk/mng/computed/staffFee/edit').reply(config => {
      var params = JSON.parse( config.data );
      let { mkStaff,orderId,orderTotalFee,orderTotalAmount,orderActPayAmount,orderReduceAmount,custId,flowId,status,flowStatus,acctDate,accountDate,staffFee,startComputedDate,id,feeDesc,orderPayDate,feePct,staffCount,districtId,mkStaffName,custName } = params;
      _StaffFees.some(staffFee => {
        if (staffFee.id === id) {
			staffFee.mkStaff = mkStaff;
			staffFee.orderId = orderId;
			staffFee.orderTotalFee = orderTotalFee;
			staffFee.orderTotalAmount = orderTotalAmount;
			staffFee.orderActPayAmount = orderActPayAmount;
			staffFee.orderReduceAmount = orderReduceAmount;
			staffFee.custId = custId;
			staffFee.flowId = flowId;
			staffFee.status = status;
			staffFee.flowStatus = flowStatus;
			staffFee.acctDate = acctDate;
			staffFee.accountDate = accountDate;
			staffFee.staffFee = staffFee;
			staffFee.startComputedDate = startComputedDate;
			staffFee.id = id;
			staffFee.feeDesc = feeDesc;
			staffFee.orderPayDate = orderPayDate;
			staffFee.feePct = feePct;
			staffFee.staffCount = staffCount;
			staffFee.districtId = districtId;
			staffFee.mkStaffName = mkStaffName;
			staffFee.custName = custName
          return true;
        }
      });
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve([200, {
            tips:{
            	isOk:true,
            	msg:'编辑成功'
            }
          }]);
        }, 500);
      });
    });

    //新增
    mock.onPost('/mk/mng/computed/staffFee/add').reply(config => {
      var params = JSON.parse( config.data );
      let { mkStaff,orderId,orderTotalFee,orderTotalAmount,orderActPayAmount,orderReduceAmount,custId,flowId,status,flowStatus,acctDate,accountDate,staffFee,startComputedDate,id,feeDesc,orderPayDate,feePct,staffCount,districtId,mkStaffName,custName } = params;
      _StaffFees.push({
		mkStaff:mkStaff,
		orderId:orderId,
		orderTotalFee:orderTotalFee,
		orderTotalAmount:orderTotalAmount,
		orderActPayAmount:orderActPayAmount,
		orderReduceAmount:orderReduceAmount,
		custId:custId,
		flowId:flowId,
		status:status,
		flowStatus:flowStatus,
		acctDate:acctDate,
		accountDate:accountDate,
		staffFee:staffFee,
		startComputedDate:startComputedDate,
		id:id,
		feeDesc:feeDesc,
		orderPayDate:orderPayDate,
		feePct:feePct,
		staffCount:staffCount,
		districtId:districtId,
		mkStaffName:mkStaffName,
		custName:custName
      });
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve([200, {
            tips:{
            	isOk:true,
            	msg:'新增成功'
            }
          }]);
        }, 500);
      });
    });

  }
};